 import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'main',
    component: Main,
    children:[
      {
        path:'/home',
        name:'home',
        component:()=>import('../views/home')
      },
      {
        path:'/user',
        name:'user',
        component:()=>import('../views/User')
      },{
        path:'/mall',
        name:'mall',
        component:()=>import('../views/Mall')
      },{
        path:'/page1',
        name:'page1',
        component:()=>import('../views/Other/PageOne.vue')
      },{
        path:'/page2',
        name:'page2',
        component:()=>import('../views/Other/PageTwo.vue')
      }
    ]
  }
  
]
// 获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
// 修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
